home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dicecache / init.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  1KB  |  68 lines

  1. /*
  2.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  3.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  4.  *    DICE-LICENSE.TXT.
  5.  */
  6.  
  7. /*
  8.  *  INIT.C
  9.  */
  10.  
  11. #include "defs.h"
  12.  
  13. Prototype void InitC(void);
  14. Prototype void UnInitC(void);
  15.  
  16. Prototype SignalSemaphore SemLock;
  17. Prototype List    CacheList[HSIZE];
  18. Prototype List    SuffixList;
  19. Prototype short DDebug;
  20.  
  21. SignalSemaphore SemLock;
  22. List    CacheList[HSIZE];
  23. List    SuffixList;
  24. short    DDebug = 0;
  25.  
  26. void
  27. InitC(void)
  28. {
  29.     short i;
  30.     List *list;
  31.  
  32.     Forbid();
  33.     CacheMax     = (AvailMem(MEMF_CHIP) + AvailMem(MEMF_FAST)) / 4;
  34.     if (CacheMax < 32768)
  35.     CacheMax = 32768;
  36.     CacheMaxFile = CacheMax >> 2;
  37.     Permit();
  38.  
  39.     NewList(&SuffixList);
  40.     for (i = 0, list = CacheList; i < HSIZE; ++i, ++list)
  41.     NewList(list);
  42.     InitSemaphore(&SemLock);
  43. }
  44.  
  45. void
  46. UnInitC(void)
  47. {
  48.     short i;
  49.  
  50.     {
  51.     List *list;
  52.     CacheNode *cnode;
  53.  
  54.     for (i = 0, list = CacheList; i < HSIZE; ++i, ++list) {
  55.         while (cnode = GetHead(list))
  56.         DiceCacheClose(cnode);
  57.     }
  58.     }
  59.     {
  60.     Node *node;
  61.  
  62.     while (node = RemHead(&SuffixList)) {
  63.         FreeMem(node, sizeof(Node) + strlen(node->ln_Name) + 1);
  64.     }
  65.     }
  66. }
  67.  
  68.